import re


class singlePageAnalyse:
    def __init__(self):
        pass

    def isInDict(self, patt, text):
        try:
            # 使用具体的异常类型代替裸的except
            match = re.search(patt, text, flags=re.MULTILINE | re.DOTALL)
            if match:
                return True
            else:
                return False
        except re.error as e:
            # print(f"正则表达式错误: {e}")
            raise e

    def getContent(self, text):
        return re.sub('<.*?>', '', text)

    def convert_to_ten_thousand_unit(self, price):
        if price == ' - ':
            return price
        if isinstance(price, int):
            return '-'
        if price is None:
            return '-'
        if isinstance(price, str):
            try:
                price = float(price.replace(',', ''))
            except ValueError as e:
                raise e
                return None
        return round(price / 10000, 2)

